package com.wms.service.impl;

import com.wms.dao.ColorDao;
import com.wms.model.Color;
import com.wms.model.PageBean;
import com.wms.service.ColorService;
import com.wms.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
 * @author This
 * @version 1.0
 * @date 2019/7/25 21:29
 */
@Service
@Transactional
public class ColorServiceImpl extends BaseServiceImpl<Color> implements ColorService {

    @Autowired
    private ColorDao dao;

    @Override
    public boolean add(Color color) {
        List<Color> list = dao.findByCondition("colName=? ", color.getColName());
        if (!CommonUtils.isEmpty(list)) {
            return false;
        }
        dao.save(color);
        return true;
    }

    @Override
    public void delete(Color color) {
        dao.delete(color);
    }

    @Override
    public void edit(Color color) {

    }

    @Override
    public Color find(Serializable id) {
        return null;
    }

    @Override
    public void deleteAll(String ids) {
        ids = " id in ( " + ids + " )";
        dao.deleteAll(ids);
    }

    @Override
    public void pageQuery(PageBean<Color> pb) {
        try {
            dao.pageQuery(pb);
        } catch (Exception e) {
        }
    }

    @Override
    public List<Color> findAll() {
        return dao.findAll();
    }
}
